﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AcctrueWMS.Foundation.DAL;
using AcctrueWMS.Foundation.Common.Exception;
namespace AcctruePMS.Bll.Common
{
    class CommonFunctions
    {
        /// <summary>
        /// 删除单条记录
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="condition">条件</param>
        /// <returns></returns>
        public string DeleteSingleDate(string tableName, string keyValueExpress)
        {
            if (string.IsNullOrEmpty(keyValueExpress)) return "Fail";
            string[] keyValues = keyValueExpress.Split('|');

            string execSQL = "";
            StringBuilder sbSql = new StringBuilder();
            foreach (string str in keyValues)
            {
                sbSql.AppendFormat("delete from {0} where  {1};", tableName, str);
            }

            execSQL = sbSql.ToString();
            try
            {
                int i = WMSqlExcuter.ExecuteRealNonQuery(execSQL);
                if (i < 1)
                {
                    return "Fail";
                }
            }
            catch (Exception)
            {
                throw new WMSBllException(string.Format("数据操作失败！"));
            }

            return "OK";
        }
    }
}
